<?php
require_once('simpletest/autorun.php');
require_once('simpletest/browser.php');
require_once('../PHP/savedPostGetter.php');

//Simple Unit tests checking Databse connection, inserts removes and correct order
class getSavePostTest extends UnitTestCase {
//covers Code coverage for data as well as constructor
    function testDatabaseConnection (){
        $link = mysql_connect('localhost', 'root', '');
          if (!$link) {
            $this->assertTrue(1==0);
          }
          else{

            $this->assertTrue(1==1);
          }
    }

    //make sure the test db is empty before each test
    function setUp() {
			$link = mysql_connect('localhost', 'root', '');
			if (!$link) {
				die('Not connected : ' . mysql_error());
			}
			$db_selected = mysql_select_db('FinalProject', $link);
			if (!$db_selected) {
				die ('Can\'t use Final Project: ' . mysql_error());
			}
        }

        function testInsertPost(){
			$_COOKIE['usr']='caae711805efd34c72d59a24083da89b5883727675550ed3f2811771213d55f8';
			$savedPosts = new SavedPostGetter();
            
			$this->assertTrue(count($savedPosts->posts)==1);
        }
}

?>